#include <iostream>
using namespace std;

template <class Element> class Field{
		public:
	
			virtual const Element& invert(const Element& op1, Element& res=_res) = 0;
		protected:
			static Element _res; // default result holder
};


template <class Element> class myField: public Field<Element>{
	public:
			const Element& increase(Element& e){e+=1; return e; }
			const Element& invert(const Element& op1, Element& res=Field<Element>::_res){
				res=1/op1;
				return res;
			}
};


template <class Element> class myField2: public Field<Element>{
	public:
			const Element& increase(Element& e){e+=2; return e; }
			const Element& invert(const Element& op1, Element& res=Field<Element>::_res){
				res=1+1/op1;
				return res;
			}
};


template <class Element> class myField3: public Field<Element>{
	public:
			const Element& increase(Element& e){e+=2; return e; }
	};


// template <> int Field<int>::_res=0;
template <> float Field<float>::_res=0.0;

int main(){
	float e=3.0;
	Field<float>* F;
	F=new myField<float>;
	cout <<F->invert(e)<<endl; 
	delete F;
	
	F=new myField2<float>;
	
	cout <<F->invert(e)<<endl;

	delete F;

	// F=new myField3<float>; delete F;

	
	// Field<float> Ff;
	return 0;

}
